package main

import (
	"fmt"
	"strings"
)

func main() {

	var name = "baim0"
	var upName = strings.ToUpper(name) // 全部改成大写

	fmt.Println(upName)

	var lowName = strings.ToLower(name) // 全部改成小写
	fmt.Println(lowName)

	var s = "hello baim0"
	result1 := strings.HasPrefix(s, "hello") // 开头
	fmt.Println(result1)

	result2 := strings.HasSuffix(s, "m0") // 结尾
	fmt.Println(result2)

	result3 := strings.Contains(s, "m0") // 包含
	fmt.Println(result3)


	username:="  baim0   "
	// 去除两端空格
	username2:= strings.Trim(username," ")
	username3:=strings.TrimSpace(username)
	username4:=strings.TrimLeft(username," ")
	username5:=strings.TrimRight(username," ")
	fmt.Println(username2)
	fmt.Println(username3)
	fmt.Println(username4)
	fmt.Println(username5)

	// index 索引
	var s2 = "hello baim0"
	fmt.Println(strings.Index(s2,"baim0"))

	// 分割 拼接
	var s3 = "hello baim0"
	s4:=strings.Split(s3," ")
	fmt.Println(s4[0]) // hello
	fmt.Println(s4[1]) // baim0

	s5:=strings.Join(s4,",")
	fmt.Println(s5)
}
